/**
 * Copyright(c) 2003-2007 Observant Pty Ltd 
 * All rights reserved.
 */

package com.ctn.util.exception;

/**
 * This exception is raised when an invlid query is specified.
 * 
 * @author jima
 */
public class InvalidResourceQueryException extends RingoCoreResourceException {
	/**
	 * Default suide
	 */
	private static final long serialVersionUID = 1L;
	/**
	 * The query string
	 */
	private String queryString;
	
	/**
	 * Create an exception by specifying the query string that is in  error
	 * 
	 * @param queryString
	 *			the query string 		
	 */
	public InvalidResourceQueryException(String queryString) {
		super();
		this.queryString = queryString;
	}
	
	/**
	 * Create an exception specifying the query string and a message
	 * 
	 * @param queryString
	 *			the query string
	 * @param message
	 * 			the message 		
	 */
	public InvalidResourceQueryException(String queryString, String message) {
		super(message);
		this.queryString = queryString;
	}

	/**
	 * Create an exception specifying the query string, a message and a 
	 * nested exception
	 * 
	 * @param queryString
	 * 			the query string
	 * @param message
	 * 			the message
	 * @param exception	
	 * 			the nested exception
	 */
	public InvalidResourceQueryException(String queryString, String message, Throwable exception) {
		super(message, exception);
		this.queryString = queryString;
	}

	/**
	 * @return the queryString
	 */
	public String getQueryString() {
		return queryString;
	}

	/* (non-Javadoc)
	 * @see java.lang.Throwable#toString()
	 */
	@Override
	public String toString() {
		return new StringBuffer("Error in query: ")
			.append(this.queryString)
			.append(" msg=")
			.append(getMessage())
			.append("\n")
			.toString();
	}
	
}
